#pragma once

#include "SFML\Graphics.hpp"
#include "config.h"

namespace game
{
	class Camera
	{
		sf::Vector2f _pos;
		sf::Vector2u _size;
	public:
		Camera(sf::Vector2f pos, sf::Vector2u size)
		{
			_pos = pos;
			_size = size;
		}
		void				set_position(sf::Vector2f new_pos){_pos = new_pos;}
		const sf::Vector2f	get_position(){return _pos;}const

		void				set_size(sf::Vector2u new_size){_size = new_size;}
		const sf::Vector2u	get_size(){return _size;}const

		bool is_point_in_view(sf::Vector2u point) const
		{
			float min_x = _pos.x - _size.x;
			float max_x = _pos.x + _size.x;
			float min_y = _pos.y - _size.y;
			float max_y = _pos.y + _size.y;
			if (point.x >= min_x && point.x < max_x)
			{
				if(point.y > min_y && point.y <= max_y)
				{
					return true;
				}
			}
			return false;
		}
		bool is_range_in_view(bool range_is_x_not_y,int val, int range) const
		{
			float min = 0,max = 0;
			if (range_is_x_not_y)
			{
				min = _pos.x - _size.x;
				max = _pos.x + _size.x;
			}
			else
			{
				min = _pos.y - _size.y;
				max = _pos.y + _size.y;
			}
			bool in_x = (val >= min-range && val < max);
			bool in_y = (val > min && val < max + range);

			if (range_is_x_not_y){return in_x;}else{return in_y;}
		}
		bool is_rectangle_in_view(sf::Vector2u point, sf::Vector2u size) const
		{
			float min_x = _pos.x - _size.x;
			float max_x = _pos.x + _size.x;
			float min_y = _pos.y - _size.y;
			float max_y = _pos.y + _size.y;

			if (point.x >= min_x-size.x && point.x < max_x)
			{
				if(point.y > min_y && point.y <= max_y + size.y)
				{
					return true;
				}
			}
			return false;
		}
	};
}